/*
 * person.hpp
 *
 *  Created on: 2020年4月10日
 *      Author: guyadong
 */

#ifndef SIMPLEMQ_REDIS_EXAMPLES_PERSON_HPP_
#define SIMPLEMQ_REDIS_EXAMPLES_PERSON_HPP_
#include <string>
#include <cstdint>
#include <sstream>
#include <json_utilits.hpp>
struct person {
	std::string name;
	int32_t age;
	int32_t id;
	std::string to_string()const {
		std::stringstream ss;
		ss << "person(" << "name=" << name << ",age=" << age << ",id=" << id << ")";
		return ss.str();
	}
};

inline std::ostream& operator<<(std::ostream& out, const person &p) {
	out << p.to_string();
	return out;
}
_BASIC_JSON_TPL_DECLARATION_
void to_json(_BASIC_JSON_TPL_ &j,const person& p) {
	j["name"] = p.name;
	j["age"] = p.age;
	j["id"] = p.id;
}
_BASIC_JSON_TPL_DECLARATION_
void from_json(const _BASIC_JSON_TPL_ &j, person& p) {
	p.name = j["name"].template get<std::string>();
	p.age = j["age"].template get<uint32_t>();
	p.id = j["id"].template get<uint32_t>();
}


#endif /* SIMPLEMQ_REDIS_EXAMPLES_PERSON_HPP_ */
